home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 2.iso
/
STUTTGART
/
TEX-UTIL
/
DVI_DVI1
/
dvilj
/
c
/
dvichars
< prev
next >
Wrap
Text File
|
1996-01-07
|
30KB
|
1,084 lines
#include "dvilj.h"
/*-->EmitChar*/
/**********************************************************************/
/**************************** EmitChar ******************************/
/**********************************************************************/
void /* output a character bitmap */
EmitChar(long4 c, struct char_entry *ce)
{
register int i;
register unsigned char *sl;
unsigned short nbpl, nwpl;
long4 total;
#ifdef LJ
unsigned char cnv_buffer[10];
#endif
#ifdef LJ
/*
printf("Emit character %c(%d) id=%d, yoff=%d[%d], w=%d[%d], h=%d[%d]\n",
(char)c,(int)c,
fontptr->plusid,
ce->yOffset, fontptr->max_yoff,
ce->width, fontptr->max_width,
ce->height, fontptr->max_height
);
*/
#endif
if ( fontptr->ncdl == 0 ) {
#ifdef IBM3812
used_fontstorage += 1028;
#endif
#ifdef LJ
if (fontptr->max_width == 0) { /* we have no realistic values */
fontptr->max_yoff = CHAR_HEIGTH_LARGE;
fontptr->max_width = CHAR_WIDTH_LARGE;
fontptr->max_height = CHAR_HEIGTH_LARGE*2;
}
/* open font dict before first char, set active font */
INT_ASCII(cnv_buffer,fontptr->plusid);
#ifdef LJ4
EMIT(EMTO, "\033*c%sD\033)s68W", cnv_buffer); EMFLUSH;
EMITB(6, "\0\104\024\2\0\0");
#else
EMIT(EMTO, "\033*c%sD\033)s26W", cnv_buffer); EMFLUSH;
#ifdef SEVENBIT
EMITB(6, "\0\032\0\1\0\0");
#else
EMITB(6, "\0\032\0\2\0\0");
#endif
#endif /* LJ 4 */
EMITWORD( fontptr->max_yoff);
EMITWORD( fontptr->max_width);
EMITWORD( fontptr->max_height);
EMITB(8, "\0\1\1\25\0\4\0\4");
EMITB(6, "\0\0\0\0\0\0");
#ifdef LJ4
EMITB(22,"\0\0\0\0\0\0\0\0\0\0\0\0\0\377\0\0\0\0\0\0\0\0");
EMITB(16," ");
EMITB(4 ,"\2\130\2\130");
#endif
EMIT(EMTO, "\033*c4F"); EMFLUSH;
#endif
}
if ( fontptr != prevfont ) { /* because this isn't done on pass 0 */
#ifdef LJ
INT_ASCII(cnv_buffer,fontptr->plusid);
EMIT(EMTO, "\033(%sX", cnv_buffer); EMFLUSH;
#endif
prevfont = fontptr;
}
#ifdef USEPXL
if (fontptr->id == pk89) {
nwpl = 0; /* initialize variable */
nbpl = ((int)(ce->width) + 7) >> 3;
total = (long4)ce->height * nbpl;
} else if (fontptr->id == id1002) {
nwpl = 0; /* initialize variable */
nbpl = ((int)(ce->width) + 7) >> 3;
total = (long4)ce->height * nbpl;
} else if (fontptr->id == id1001) {
nwpl = ((int)(ce->width) + 31) >> 5;
nbpl = ((int)(ce->width) + 7) >> 3;
total = (long4)ce->height * nbpl;
} else {
/* should never be necessary */
nwpl = 0;
nbpl = 0;
total = 0;
}
#else
nbpl = (num_cols + 7) >> 3;
total = num_rows * nbpl;
#endif
/***************************************************************
if ( ((char) c == 'i') && (fontptr->plusid == 0)) {
long4 j;
fprintf(ERR_STREAM, "cols=%ld, ncols=%ld\n",(long)nwpl,(long)nbpl);
fprintf(ERR_STREAM, "%ld Bytes:->",(long)total);
for (j=0; j<total;j++) {
char *ch; char ic;
ch = (char *)(ce->where.address.pixptr);
ic = *(ch+j);
fprintf(ERR_STREAM,"%X.",ic);
}
fprintf(ERR_STREAM,"<- Now Emitting\n");
}
***************************************************************/
#ifdef USEPXL
#ifdef IBM3812
if ((short)(ce->height) - ce->yOffset > 55) {
ce->yyOffset = (short) ce->height - ce->yOffset;
ce->yOffset = (short) ce->height;
} else {
ce->yyOffset = (short) 0;
}
#endif
#ifdef LJ
ce->yyOffset = (short) 0;
#endif
#endif
/* ce->cw = (long4)(((double)ce->tfmw / (double)hconv) +0.5); */
/* set active font to nn, load font pattern xx ... */
#ifdef IBM3812
PMPcont(total + 9);
#ifdef USEPXL
sprintf(PMPformat, "\323%c\360%c%c%c",
(unsigned char)fontptr->plusid,
(unsigned char)VisChar((char)c),
(unsigned char)ce->height,
(unsigned char)ce->width);
PMPout(6, PMPformat);
PMPoutC((char)(-(ce->xOffset)));
PMPoutC((char)(ce->cw - (-ce->xOffset + ce->width)));
PMPoutC((char)(ce->yOffset));
#else
sprintf(PMPformat, "\323%c\360%c%c%c",
(unsigned char)fontptr->plusid,
(unsigned char)VisChar((char)c),
(unsigned char)num_rows,
(unsigned char)num_cols);
PMPout(6, PMPformat);
PMPoutC((char)(-x_offset));
PMPoutC((char)(ce->cw - (-x_offset + num_cols)));
PMPoutC((char)num_rows-y_offset);
#endif
#endif
#ifdef LJ
INT_ASCII(cnv_buffer,fontptr->plusid);
EMIT(EMTO, "\033*c%sd%dE\033(s%ldW", cnv_buffer,
(unsigned int)VisChar((char)c), (long)(total + 16)); EMFLUSH;
EMITB(4, "\4\0\016\1");
/* EMITC((char)(Landscape==_TRUE)); */
EMITC((char)0);
EMITC((char)0);
#ifdef USEPXL
EMITWORD(-ce->xOffset);
EMITWORD(ce->yOffset);
EMITWORD(ce->width);
EMITWORD(ce->height);
#else
EMITWORD(-x_offset);
EMITWORD(num_rows-y_offset);
EMITWORD(num_cols);
EMITWORD(num_rows);
#endif
EMITWORD((int)ce->cw * 4);
#endif
#ifdef USEPXL
if (fontptr->id == pk89)
PkRaster(ce, _FALSE);
else if (fontptr->id == id1002)
for (i = 0; i < (int) ce->height; i++) {
sl = ((unsigned char *)(ce->where.address.pixptr) + i * nbpl);
EMITL(nbpl, sl);
}
else if (fontptr->id == id1001)
for (i = 0; i < (int) ce->height; i++) {
sl = (unsigned char *)(ce->where.address.pixptr + i * nwpl);
EMITL(nbpl, sl);
}
#else
for (i = num_rows; i > 0; i--)
{
EMITL (nbpl, bits + (i-1) * nbpl);
}
#endif
#ifdef IBM3812
#ifdef USEPXL
used_fontstorage += (long4)ce->height * ((ce->width + 15) >> 4)
*2 + 14;
#else
used_fontstorage += (long4)num_rows * ((num_cols + 15) >> 4)
*2 + 14;
#endif
#endif
#ifdef LJ
#ifdef USEPXL
used_fontstorage += 64 * (((int)((ce->height * ce->width) - 1) / 64) + 1);
#else
used_fontstorage += 64 * ((((num_rows * num_cols) - 1) / 64) + 1);
#endif
#endif
fontptr->ncdl += 1;
G_ncdl += 1;
}
/*********************************************************************/
/**************************** PK Raster ******************************/
/*********************************************************************/
#ifdef USEPXL
bool getbit ();
unsigned char getnyb (void);
long4 pk_packed_num (void);
#define PKBYTE *pkloc; pkloc ++
#define OUTCHAR(c) raster_line_buf[bp]= (unsigned char)c; bp++
unsigned char bitweight, inputbyte ;
unsigned char dyn_f ;
unsigned char *pkloc;
int repeatcount;
void /* <Read and translate raster description@>*/
PkRaster(struct char_entry *ce, bool raster)
{
int rp;
int current_line;
int wordwidth ;
bool turnon;
unsigned short nbpl;
long4 rowsleft, word, wordweight, hbit, count, i, j, tl;
long4 row[101] ;
unsigned char raster_line_buf[BYTES_PER_PIXEL_LINE];
unsigned short bp;
if (ce->charsize == HUGE_SIZE)
Fatal( "cannot process currently PK font patterns of that size!\n");
current_line = 0;
pkloc = (unsigned char *)ce->where.address.pixptr;
dyn_f = (unsigned char)(ce->flag_byte >> 4);
turnon = (bool)((ce->flag_byte & 8) == 8);
wordwidth = (int)(ce->width + 31) >> 5 ;
nbpl = ((int)(ce->width) + 7) >> 3;
bitweight = 0 ;
if (dyn_f == 14) {
/*printf("<Get raster by bits@>\n");*/
for (i = 1; i <= (long4)ce->height; i++) {
word = 0 ;
wordweight = 31 ;
bp = 0; /* Sowa */
#ifdef DRAWGLYPH
printf(" |");
#endif
for (j = 1; j <= (long4) ce->width; j++) {
bool getbit;
/* bp = 0; SOWA */
/*******************************************begin Getbit *********/
bitweight /= 2 ;
if ( bitweight == 0 ) {
inputbyte = PKBYTE ;
bitweight = 128 ;
}
getbit = (bool)
( inputbyte >= bitweight ) ;
if ( getbit )
inputbyte -= bitweight ;
/*********************************************end Getbit *********/
if (getbit)
word += power[wordweight] ;
wordweight --;
if (wordweight == -1) {
#ifdef DRAWGLYPH
{ int k;
for (k=31; k>=0; k--) {
if ((power[k] & word)!=0) printf("M");
else printf(".");
}
}
#endif
OUTCHAR((word >> 24 & 0xFF));
OUTCHAR((word >> 16 & 0xFF));
OUTCHAR((word >> 8 & 0xFF));
OUTCHAR((word & 0xFF));
word = 0 ;
wordweight = 31 ;
}
}
if (wordweight < 31) {
#ifdef COMMENT
#ifdef DRAWGLYPH
{ int k;
for (k=15; k>=0; k--) {
if ((power[k] & word)!=0) printf("Z");
else printf(":");
}
}
printf("|\n ----|");
#endif
#endif
for (j = 3; j >= (wordwidth * 4 - (long4)nbpl);
j--) {
OUTCHAR(((word >> (j << 3)) & 0xff));
#ifdef DRAWGLYPH
{ int k;
for (k=7; k>=0; k--) {
if ((power[k] & ((word >> (j << 3)) & 0xff))!=0) printf("M");
else printf(".");
}
}
#endif
}
}
if (raster) {
RasterLine(ce, (unsigned int)nbpl,
current_line, raster_line_buf);
current_line++;
} else
EMITL(bp, raster_line_buf);
#ifdef DRAWGLYPH
printf("|\n");
#endif
}
} else {
/* fprintf(ERR_STREAM, "@<Create normally packed raster@>\n"); */
rowsleft = (long4) ce->height ;
hbit = (long4) ce->width ;
repeatcount = 0 ;
wordweight = 32 ;
word = 0 ;
rp = 1 ;
while ( rowsleft > 0 ) {
count = pk_packed_num() ;
bp = 0;
while (count > 0) {
if ((count < wordweight) && (count < hbit)) {
if (turnon)
word +=
gpower[wordweight] -
gpower[wordweight - count] ;
hbit -= count ;
wordweight -= count ;
count = 0 ;
} else if ((count >= hbit) && (hbit <=
wordweight)) {
if (turnon)
word +=
gpower[wordweight] -
gpower[wordweight - hbit] ;
row[rp] = word ;
/*fprintf(ERR_STREAM, " @<Send row@> \n");*/
for (i = 0; i <= (long4) repeatcount; i++) { int ii;
#ifdef DRAWGLYPH
printf("*** |");
#endif
for (ii = 1; ii < wordwidth; ii++) {
tl = row[ii];
OUTCHAR((tl >> 24 & 0xFF));
OUTCHAR((tl >> 16 & 0xFF));
OUTCHAR((tl >> 8 & 0xFF));
OUTCHAR((tl & 0xFF));
#ifdef DRAWGLYPH
{ int k;
for (k=31; k>=0; k--) {
if ((power[k] & row[ii])!=0) printf("M");
else printf(".");
}
}
#endif
}
tl = row[wordwidth];
for (j = 3; j >= (wordwidth *4 - (long4)nbpl);
j--) {
OUTCHAR(((tl >> (j << 3)) & 0xff));
#ifdef DRAWGLYPH
{ int k;
for (k=7; k>=0; k--) {
if ((power[k] & ((tl >> (j << 3)) & 0xff))!=0) printf("M");
else printf(".");
}
}
#endif
}
if (raster) {
RasterLine(ce,
(unsigned int)nbpl,
current_line,
raster_line_buf);
current_line++;
} else
EMITL(bp, raster_line_buf);
bp = 0;
#ifdef DRAWGLYPH
printf("| ");
for (j=1;j<=(long4)wordwidth;j++) printf("%02lX/",row[j]);
printf(" raster=%d\n",raster);
#endif
}
rowsleft -= (long4)repeatcount + 1 ;
repeatcount = 0 ;
rp = 1 ;
word = 0 ;
wordweight = 32 ;
count -= hbit ;
hbit = (long4)ce->width ;
} else {
if (turnon) word += gpower[wordweight] ;
row[rp] = word ;
rp = rp + 1 ;
word = 0 ;
count -= wordweight ;
hbit -= wordweight ;
wordweight = 32 ;
}
} /* .....while count > 0 */
if (turnon)
turnon = _FALSE;
else
turnon = _TRUE;
} /* ...... rowsleft > 0 */
if ((rowsleft != 0) || (hbit != (long4)ce->width))
Fatal("Bad pk file----more bits than required!\n");
} /* .... create normally packed raster */
}
unsigned char getnyb (void)
{
register unsigned char temp ;
if ( bitweight == 0 ) {
inputbyte = PKBYTE ;
bitweight = 16 ;
}
temp = inputbyte / bitweight ;
inputbyte -= temp * bitweight ;
bitweight /= 16 ;
return ( temp ) ;
}
long4
pk_packed_num (void)
{ /*@<Packed number procedure@>= */
register int i;
long4 j;
i = (int)getnyb();
if (i == 0) {
do {
j = (long4)getnyb();
i++;
} while (j == 0) ;
while (i > 0) {
j = j * 16 + (long4)getnyb() ;
i--;
};
return (j - 15 + (13 - dyn_f) * 16 + dyn_f) ;
} else if (i <= (int)dyn_f) {
return ((long4)i);
} else if (i < 14) {
return ((i-(long4)dyn_f - 1) * 16 + (long4)getnyb() + dyn_f + 1);
} else {
if (i == 14) {
repeatcount = (int) pk_packed_num() ;
} else {
repeatcount = 1 ;
}
/* fprintf(ERR_STREAM,"repeatcount = [%d]\n",repeatcount); */
return (pk_packed_num()) ; /* tail end recursion !! */
}
}
#endif
#ifndef USEPXL
void bad_gf(int n)
{
Fatal("Bad gf file, case %d\n",n); /* See gf.c */
}
#endif
/*-->RasterLine*/
/**********************************************************************/
/**************************** RasterLine ****************************/
/**********************************************************************/
void
RasterLine(struct char_entry *ce, unsigned short nbpl, unsigned short current_line, char *buffer)
{
#ifdef IBM3812
long4 total;
static unsigned short maxlines;
if (current_line == 0) {
#ifdef USEPXL
maxlines = ce->height;
MoveVert(-ce->yOffset); /* move cursor up */
MoveHor(-ce->xOffset); /* move cursor right */
#else
maxlines = num_rows;
MoveVert(-(num_rows-y_offset)); /* move cursor up */
MoveHor(-x_offset); /* move cursor right */
#endif
last_ry = UNKNOWN; /* next time full positioning */
}
if (current_line % maxlines == 0) {
if (current_line > 0) { /* maxlines lines have been printed*/
MoveVert(maxlines); /* move cursor down */
last_ry = UNKNOWN; /* next time full positioning */
}
#ifdef USEPXL
total = (long4)(ce->height - current_line) * (long4)nbpl;
#else
total = (long4)(num_rows - current_line) * (long4)nbpl;
#endif
if ((total + 9) > 65535) {
maxlines = (unsigned short)((65535 - 9) / nbpl);
total = (long4)maxlines * (long4)nbpl;
}
PMPcont(total + 9);
PMPout(2, "\365\0");
EMITWORD(maxlines);
#ifdef USEPXL
EMITWORD(ce->width);
#else
EMITWORD(num_cols);
#endif
PMPoutC((unsigned char) (total >> 16) & 0xFF);
PMPoutC((unsigned char) (total >> 8 ) & 0xFF);
PMPoutC((unsigned char) total & 0xFF);
}
EMITL((int)nbpl, buffer);
#endif
#ifdef LJ
register int emitbytes;
for (emitbytes = (int)nbpl;
(*(buffer + emitbytes - 1) == '\0') && (emitbytes > 0);
emitbytes--) ;
EMIT(EMTO, "\033*b%dW", emitbytes); EMFLUSH;
EMITL(emitbytes, buffer);
#endif
}
/*-->RasterChar*/
/**********************************************************************/
/**************************** RasterChar ****************************/
/**********************************************************************/
void /* raster a character bitmap */
RasterChar(struct char_entry *ce)
{
int i;
register unsigned char *sl;
unsigned short nbpl, nwpl;
unsigned char raster_line_buf[BYTES_PER_PIXEL_LINE];
#ifdef DEBUG
if (Debug)
fprintf(ERR_STREAM,"Raster character ...size=%d \n", (int)ce->charsize );
#endif
#ifdef USEPXL
if (fontptr->id == pk89) {
nwpl = 0; /* initialize variable */
nbpl = ((int)(ce->width) + 7) >> 3;
} else if (fontptr->id == id1002) {
nwpl = 0; /* initialize variable */
nbpl = ((int) ce->width + 7) >> 3;
} else if (fontptr->id == id1001) {
nwpl = ((int) ce->width + 31) >> 5;
nbpl = ((int) ce->width + 7) >> 3;
} else {
/* should never be necessary */
nwpl = 0;
nbpl = 0;
}
#else
nbpl = (num_cols + 7) >> 3;
#endif
#ifdef LJ
EMIT(EMTO, "\033*t%dR\033*r1A",RESOLUTION); EMFLUSH;
#endif
{ /* read pixel from file */
if ((ce->charsize == HUGE_SIZE) && (fontptr->id != pk89))
OpenFontFile();
#ifdef USEPXL
FSEEK(pxlfp, ce->where.address.fileOffset,SEEK_SET);
#else
FSEEK(gfin, ce->where.address.fileOffset,SEEK_SET);
gettochar();
readbits();
#endif
}
#ifdef USEPXL
if (fontptr->id == pk89)
PkRaster(ce, _TRUE);
else if (fontptr->id == id1002) {
for (i = 0; i < (int) ce->height; i++) {
if (ce->charsize == HUGE_SIZE) {
read_multi(raster_line_buf, 1, (int) nbpl, pxlfp);
sl = raster_line_buf;
} else
sl = ((unsigned char *)(ce->where.address.pixptr)
+ i * nbpl);
RasterLine(ce, (unsigned int)nbpl, i, sl);
}
} else if (fontptr->id == id1001) {
long4 filediff;
filediff = (long4)nwpl * 4 - nbpl;
for (i = 0; i < (int) ce->height; i++) {
if (ce->charsize == HUGE_SIZE) {
read_multi(raster_line_buf, 1, (int) nbpl, pxlfp);
/* skip fill bytes */
FSEEK(pxlfp, filediff,SEEK_CUR);
sl = raster_line_buf;
} else
sl = (unsigned char *)(ce->where.address.pixptr + i * nwpl);
RasterLine(ce, (unsigned int)nbpl, i, sl);
}
}
#else
for (i = num_rows; i > 0; i--)
RasterLine(ce, (unsigned int)nbpl, i, bits + (i-1) * nbpl);
#endif
#ifdef LJ
EMIT(EMTO, "\033*rB"); EMFLUSH;
#endif
last_ry = UNKNOWN;
}
/*-->LoadAChar*/
/**********************************************************************/
/***************************** LoadAChar ******************************/
/**********************************************************************/
void
LoadAChar(long4 c, register struct char_entry *ptr)
{
long4 *pr;
long4 bytes;
if (ptr->where.address.fileOffset == NONEXISTANT
#ifdef LJ_RESIDENT_FONTS
|| fontptr->resident_p
#endif
) {
ptr->where.isloaded = _FALSE;
return;
}
OpenFontFile();
#ifdef DEBUG
if (Debug)
fprintf(ERR_STREAM, "LoadAChar: <%c>(%ld) from file at pos %ld\n",
(char)c,(long)c,(long)ptr->where.address.fileOffset);
#endif
#ifdef USEPXL
FSEEK(pxlfp, ptr->where.address.fileOffset,SEEK_SET);
if (fontptr->id == pk89) {
#ifdef PARANOIA
unsigned char temp;
temp = (unsigned char) NoSignExtend(pxlfp, 1);
if ((int)(ptr->flag_byte) != (int)temp) {
fprintf(ERR_STREAM,"font=%lx, ptr=%lx\n",fontptr,ptr);
Fatal("%d: oh boy! old flag %d, new flag %d, ptr=%lx\n",
(int)c,(int)(ptr->flag_byte),(int)temp,ptr);
}
#endif
if ((ptr->flag_byte & 7) == 7) {
bytes = ((long4) NoSignExtend(pxlfp, 4)) - 28;
FSEEK(pxlfp, ptr->where.address.fileOffset + 36,SEEK_SET);
/*
fprintf(ERR_STREAM,"bytes=%ld, seeking at %ld\n",
(long)bytes, (long)ptr->where.address.fileOffset + 36);
*/
} else if ((ptr->flag_byte & 4) == 4) {
bytes = ((long4)ptr->flag_byte & 3)
* 65536l + NoSignExtend(pxlfp, 2) - 13;
FSEEK(pxlfp, ptr->where.address.fileOffset + 16,SEEK_SET);
} else {
bytes = ((long4)ptr->flag_byte & 3)
* 256 + NoSignExtend(pxlfp, 1) - 8;
FSEEK(pxlfp, ptr->where.address.fileOffset + 10,SEEK_SET);
}
} else if (fontptr->id == id1002)
bytes = ((( (long4)ptr->width + 7) >> 3) * (long4) ptr->height);
else if (fontptr->id == id1001)
bytes = 4 * (((long4)ptr->width + 31) >> 5) * (long4)ptr->height;
else
bytes = 0;
if (bytes > 0) {
/* do NOT load Huge characters */
if ((bytes > HUGE_CHAR_PATTERN) && (fontptr->id != pk89)) {
qfprintf(ERR_STREAM,"Huge Character <%c> (%ld Bytes)\n", (char)c, (long)bytes);
ptr->charsize = HUGE_SIZE;
ptr->where.isloaded = _FALSE;
} else {
if ( (pr = (long4 *)malloc( bytes )) == NULL )
Fatal("Unable to allocate %ld bytes for char <%c>\n",
(long)bytes, (char)c);
/*
* else fprintf(ERR_STREAM,"allocating %ld bytes char <%c>(%d)\t at 0x%lx\n",
* (long)bytes, (char)c,(int)c,(long)pr);
*/
#ifdef DEBUG
if (Debug)
fprintf(ERR_STREAM,
"Allocating Char <%c>, FileOffset=%lX, Bytes=%ld (%d) <%d>\n",
(char) c, (long)ptr->where.address.fileOffset, (long)bytes,
(int)bytes, (unsigned int)bytes);
#endif
allocated_storage += bytes;
read_multi(pr, 1, (int) bytes , pxlfp);
ptr->where.address.pixptr = pr;
}
}
#else
FSEEK(gfin, ptr->where.address.fileOffset,SEEK_SET);
gettochar();
readbits();
if (num_bytes > HUGE_CHAR_PATTERN)
ptr->charsize = HUGE_SIZE;
#endif
ptr->where.isloaded = _TRUE;
if (ptr->charsize != SMALL_SIZE
#ifdef LJ
/* we might have problems at the edge of the paper with diff. sized characters
* the correct treatment would be to check whether the bounding box of
* tfontptr is within the paper relative to the current position
*/
|| fontptr->max_height > CHAR_HEIGTH_LARGE
|| (rasterfont[fontptr->plusid])
#endif
)
return;
EmitChar(c, ptr);
#ifdef USEPXL
/* we should really free the space used by the PXL data after this
point, but it is not large, and besides, we may want to be
more clever in the future, about sending bitmaps. So keep
the data around */
#endif
}
/*-->SetChar*/
/**********************************************************************/
/***************************** SetChar ******************************/
/**********************************************************************/
void
SetChar(long4 c, short command, int PassNo, bool do_posn, bool in_string)
{
register struct char_entry *ptr; /* temporary char_entry pointer */
bool pos_after = _FALSE;
ptr = &(fontptr->ch[c]);
if (!((ptr->where.isloaded) || (ptr->charsize == HUGE_SIZE)))
LoadAChar(c, ptr);
if (PassNo == 0)
return;
if (do_posn) {
#ifdef IBM3812
if (CharStringPos>0) {
fprintf(ERR_STREAM,"!!!! That should never happen!!!\n");
CharStringOut;
}
#endif
SetPosn(h, v);
}
/*
printf("(%d) hh=%ld (+%ld/+%ld), h=%ld, xh=%ld,xhh=%ld, [%ld|%ld] ->%d\n",
(int)do_posn,(long)hh,(long)ptr->cw,(long)ptr->cw*(long)hconv,(long)h,
(long)PIXROUND(h, hconv),
(long)PIXROUND(hh, hconv),
(long)labs((hh-h)),(long)hconv,(labs((hh-h))>hconv)
);
*/
if (in_string && (labs((hh-h))>hconv)) {
#ifdef IBM3812
CharStringOut;
#endif
SetPosn(h, v);
}
/*
fprintf(ERR_STREAM,"raster?=%d - last_ry=%d, last_rx=%d,mmax-height=%d\n",
(int)last_ry < fontptr->max_height, (int)last_ry,(int)last_rx,
(int)fontptr->max_height);
*/
if (fontptr->font_file_id != NO_FILE) { /* ignore missing fonts */
if (
#ifdef LJ_RESIDENT_FONTS
!fontptr->resident_p &&
#endif
(ptr->charsize != SMALL_SIZE
#ifdef LJ
/* the LaserJet cannot print characters
* where the bounding box lies outside the
* paper edge. Missing: right paper edge
*/
|| last_ry < (int)fontptr->max_height
|| fontptr->max_height > CHAR_HEIGTH_LARGE
|| (rasterfont[fontptr->plusid])
/***** KYOCERA *****/
#ifdef SEVENBIT
|| (c==32)
#endif
/***** KYOCERA *****/
#endif
)) {
#ifdef LJ
int tmp;
char sign;
if (!do_posn) {
SetPosn(h, v);
}
#ifdef USEPXL
tmp = (int) -ptr->yOffset;
#else
tmp = (int) num_rows-y_offset;
#endif
if (tmp != 0) {
if (tmp < 0) {
sign = '-'; tmp = -tmp;
} else
sign = '+';
EMIT(EMTO, "\033*p%c%dY", sign, tmp); EMFLUSH;
}
#ifdef USEPXL
tmp = (int) -ptr->xOffset;
#else
tmp = (int) -x_offset;
#endif
if (tmp != 0) {
if (tmp < 0) {
sign = '-'; tmp = -tmp;
} else
sign = '+';
EMIT(EMTO, "\033*p%c%dX", sign, tmp); EMFLUSH;
}
#endif
#ifdef IBM3812
CharStringOut;
#endif
#ifdef DEBUG
if (Debug)
#ifndef vms
fprintf(ERR_STREAM,"Raster character <%c> %hd\n", (char) c,(short)c);
#else
fprintf(ERR_STREAM,"Raster character <%c> %d\n", (char) c,(short)c);
#endif
#endif
RasterChar(ptr);
pos_after = _TRUE;
} else {
unsigned char cc;
cc = VisChar((char)c);
#ifdef IBM3812
#ifdef USEPXL
if ( ptr->yyOffset || (!in_string) ) {
CharStringOut;
MoveVert(ptr->yyOffset);
sprintf(PMPformat, "\01%c", cc);
PMPout(2, PMPformat);
MoveVert((int)-(ptr->yyOffset));
} else {
#endif
if (CharStringPos==CHARSTRINGMAX)
CharStringOut;
CharString[CharStringPos] = cc;
CharStringPos++;
#ifdef USEPXL
}
#endif
#endif
#ifdef LJ
#define TRANSPARENTCHAR(ch) \
if ((ch == 0l) || (ch >= 7l && ch <= 15l) || (ch == 27l)) \
{EMIT(EMTO, "\033&p1X%c", (unsigned char)ch); EMFLUSH;} \
else {EMITC((unsigned char)ch);}
#ifdef USEPXL
if (ptr->yyOffset) {
#ifndef vms
EMIT(EMTO, "\033*p+%hdY", ptr->yyOffset); EMFLUSH;
TRANSPARENTCHAR(cc);
EMIT(EMTO, "\033*p-%hdY", ptr->yyOffset); EMFLUSH; /* GUGUGU 255 */
#else
EMIT(EMTO, "\033*p+%dY", ptr->yyOffset); EMFLUSH;
TRANSPARENTCHAR(cc);
EMIT(EMTO, "\033*p-%dY", ptr->yyOffset); EMFLUSH; /* GUGUGU 255 */
#endif
} else
#endif
/* EMITC( (unsigned char)c);*/
{ TRANSPARENTCHAR(cc);}
#endif
}
hh += (long4) ptr->cw*hconv;
}
if (command <= SET4)
h += ptr->tfmw;
if (pos_after) {
SetPosn(h, v);
}
}
void
DoBop(void)
{
struct font_entry *p;
#ifdef LJ
register short i;
if (fonts_used_on_this_page > MAX_FONTS_PER_PAGE) {
for (i = 0; i < HANDLE_MAX_FONTS; i++)
rasterfont[i] = _FALSE;
}
fonts_used_on_this_page = 0;
#endif
for (p = hfontptr; p; p = p->next) {
p->used_on_this_page = _FALSE;
}
}
/*-->SetString*/
/**********************************************************************/
/***************************** SetString ****************************/
/**********************************************************************/
void
SetString(short firstch, int PassNo) /* read and set a consecutive string of chars */
{
short c;
register unsigned short i;
#ifdef DEBUG
if (Debug)
fprintf(ERR_STREAM, "SetString ");
#endif
for (i = 0, c = firstch; c >= SETC_000 && c <= SETC_127; i++) {
#ifdef DEBUG
if (Debug)
fprintf(ERR_STREAM, "%d(%c) ", c, c);
#endif
SetChar((long4)c, c, PassNo, (bool)(i==0),_TRUE);
c = (short) NoSignExtend(dvifp, 1);
}
FSEEK(dvifp, -1l,SEEK_CUR); /* backup one character */
#ifdef IBM3812
CharStringOut;
#endif
#ifdef DEBUG
if (Debug)
fprintf(ERR_STREAM, "...SetString\n");
#endif
}
void
PutWord(w)
int w;
{
EMITC((char)(w >> 8) & 0xff);
EMITC((char)w & 0xff);
}
/*-->SetPosn*/
/**********************************************************************/
/***************************** SetPosn ******************************/
/**********************************************************************/
void /* output a positioning command */
SetPosn(long4 x, long4 y)
{
int rx, ry;
rx = (int)PIXROUND(x, hconv) + x_goffset;
ry = (int)PIXROUND(y, vconv) + y_goffset;
/*
* fprintf(ERR_STREAM,"setposn to %ld/%ld, %d/%d\n",(long)x,(long)y,rx,ry);
*/
#ifdef IBM3812
PMPcont(3);
PMPoutC('\340');
EMITWORD(LARGER(rx,0));
if (last_ry != ry) { /* necessary to set new y-position */
PMPcont(3);
PMPoutC('\341');
EMITWORD(LARGER(ry,0));
}
#endif
#ifdef LJ
if (last_ry != ry) /* necessary to set new y-position */
{EMIT(EMTO, "\033*p%dx%dY", LARGER(rx,0), LARGER(ry,0)); EMFLUSH;}
else
{EMIT(EMTO, "\033*p%dX", LARGER(rx,0)); EMFLUSH;}
#endif
last_ry = ry; /* last y-position on output device */
last_rx = rx; /* last x-position on output device */
/*
* must know where device "really" is horizontally, for rel. posning.
* (maybe in the future), but we always use direct positioning for
* vertical movement.
*/
/* hh = rx * hconv; */
hh = x;
vv = y;
/*
* fprintf(ERR_STREAM,"DoPosn: x=%ld, y=%ld, rx=%d, ry=%d, hh=%ld, vv=%ld\n",
* (long)x,(long)y,rx,ry,(long)hh,(long)vv);
*/
}